<?php

namespace app\common\event;

use app\common\libs\InsideApi;
use yiqiniu\inside_sdk\message_libs\MessageBuilder;

/**
 * 审核成功
 */
class RecheckSuccessEventHandler
{
    /**
     *
     * @param array $params ['mer_id'=>'','open_id'=>'xxx','name'=>'xxcc','content'=>'xxx','title'=>'xx','remark'=>'xxx']
     * @return void
     * @throws \Exception
     */
    public function handle(array $params)
    {
        $default = [
            'mer_id' => '',
            'open_id' => '',
            'name' => '',
            'content' => '注册导购',
            'title' => '您申请亿码通导购已经通过已审核~~',
            'remark' => '感谢您注册亿码通使用平台'
        ];
        $params = array_merge($default, $params);
        if ($params['mer_id'] || $params['open_id'] || empty($params['name'])) {
            return;
        }

        $data = MessageBuilder::getInstance()
            ->setReceivers(1, $params['open_id'])
            ->setUserType(1)
            ->setTpl('sale_man_recheck_success')
            ->setData([
                'title' => $params['title'],
                'name' => $params['name'],
                'content' => $params['content'],
                'time' => date('Y-m-d H:i:s'),
                'remark' => $params['remark']
            ])->getData();
        InsideApi::Message()->Send($data);
    }

}